$(document).ready(function(){
	var note = new Note(".noteOuter", ".noteBtn");
});



/**
 * Representing notes
 * @param {Object} selStr
 */
function Note(selStr, noteBtn){
	this.$noteOuter = $(selStr);
	this.$noteBtn = $(noteBtn);
	this.$notes = this.$noteOuter.children(".note");
	this.$operationOuter = this.$noteOuter.children(".noteOperationOuter");

	this.$hider = this.$operationOuter.children(".hideLink");
	this.init();
}

Note.prototype = {
	/**
	 * inititialize notes 
	 */
	init : function(){
		var _this = this;
		this.$operationOuter.hide();
		this.$notes.hide();
		_this.$operationOuter.children(".hideLink").hide();
		
		this.$hider.children(".hide").click(function(){
			var $thisHider = $(this);
			var $thisOperationOuter = $thisHider.parent().parent();
			var $thisNotes = $thisOperationOuter.siblings(".note");
			$thisOperationOuter.hide();
			$thisNotes.slideUp();
			return false;
		});
		

		
		/**
		 * slide down for the first time and slide up for the second time
		 */
		this.$noteBtn.click(function(){
			var thisBtn = this;
			var $thisBtn = $(thisBtn);
			
			var $thisOperationOuter = _this.$operationOuter.eq(_this.$noteBtn.index($thisBtn));
			var $thisNotes = $thisOperationOuter.siblings(".note");
			var $thisHider = $thisOperationOuter.children(".hideLink");
			
			if($thisOperationOuter.css("display") == "block"){
				$thisOperationOuter.hide();
				$thisNotes.slideUp();
				return false;
			}else{
				$thisOperationOuter.slideDown("slow");
				$thisNotes.slideDown("slow");
				$thisHider.slideDown("slow");
				return false;
			}
			});
			
	}
}